﻿namespace QMVnSoft.DAL
{
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class ReportDeclarationDataAccess
    {
        public DataSet KQT01GetDataSet()
        {
            DataSet set2;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            DataSet dataSet = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT01_Get";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet);
                AppDataAccess.CloseConnection(eZConnection);
                set2 = dataSet;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return set2;
        }

        public int KQT01Save(bool pb_NewChecked, DataRow row)
        {
            int num;
            SqlParameter[] values = new SqlParameter[] { 
                new SqlParameter("p_Moi_Sua", pb_NewChecked), new SqlParameter("p_Stt", row["Stt"]), new SqlParameter("p_IDKey", row["IDKey"]), new SqlParameter("p_Stt0", row["Stt0"]), new SqlParameter("p_Dien_Giai", row["Dien_Giai"]), new SqlParameter("p_Desc_EN", row["Desc_EN"]), new SqlParameter("p_TMinh", row["TMinh"]), new SqlParameter("p_Stt_Bac", row["Stt_Bac"]), new SqlParameter("p_Cong_Thuc", row["Cong_Thuc"]), new SqlParameter("p_Ts_Nc", row["Ts_Nc"]), new SqlParameter("p_Loai_Ts", row["Loai_Ts"]), new SqlParameter("p_Tk", row["Tk"]), new SqlParameter("p_Tk_Nb_Ck", row["Tk_Nb_Ck"]), new SqlParameter("p_Len_Ps_Nt", row["Len_Ps_Nt"]), new SqlParameter("p_In_Ck", row["In_Ck"]), new SqlParameter("p_Bold", row["Bold"]), 
                new SqlParameter("p_Result", SqlDbType.BigInt)
             };
            values[1].Direction = ParameterDirection.InputOutput;
            values[1].SqlDbType = SqlDbType.Int;
            values[0x10].Direction = ParameterDirection.Output;
            values[0x10].SqlDbType = SqlDbType.Int;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT01_Save";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
                row["Stt"] = values[1].Value;
                num = (int) values[0x10].Value;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return num;
        }

        public DataSet KQT02GetDataSet()
        {
            DataSet set2;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            DataSet dataSet = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT02_Get";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet);
                AppDataAccess.CloseConnection(eZConnection);
                set2 = dataSet;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return set2;
        }

        public int KQT02Save(bool pb_NewChecked, DataRow row)
        {
            int num;
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Moi_Sua", pb_NewChecked), new SqlParameter("p_Stt", row["Stt"]), new SqlParameter("p_IDKey", row["IDKey"]), new SqlParameter("p_Stt0", row["Stt0"]), new SqlParameter("p_Dien_Giai", row["Dien_Giai"]), new SqlParameter("p_Desc_EN", row["Desc_EN"]), new SqlParameter("p_TMinh", row["TMinh"]), new SqlParameter("p_Stt_Bac", row["Stt_Bac"]), new SqlParameter("p_Cong_Thuc", row["Cong_Thuc"]), new SqlParameter("p_Tk_No", row["Tk_No"]), new SqlParameter("p_Tk_Co", row["Tk_Co"]), new SqlParameter("p_In_Ck", row["In_Ck"]), new SqlParameter("p_Bold", row["Bold"]), new SqlParameter("p_Result", SqlDbType.BigInt) };
            values[1].Direction = ParameterDirection.InputOutput;
            values[1].SqlDbType = SqlDbType.Int;
            values[13].Direction = ParameterDirection.Output;
            values[13].SqlDbType = SqlDbType.Int;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT02_Save";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
                row["Stt"] = values[1].Value;
                num = (int) values[13].Value;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return num;
        }

        public DataSet KQT031GetDataSet()
        {
            DataSet set2;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            DataSet dataSet = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT031_Get";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet);
                AppDataAccess.CloseConnection(eZConnection);
                set2 = dataSet;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return set2;
        }

        public int KQT031Save(bool pb_NewChecked, DataRow row)
        {
            int num;
            SqlParameter[] values = new SqlParameter[] { 
                new SqlParameter("p_Moi_Sua", pb_NewChecked), new SqlParameter("p_Stt", row["Stt"]), new SqlParameter("p_IDKey", row["IDKey"]), new SqlParameter("p_Stt0", row["Stt0"]), new SqlParameter("p_Dien_Giai", row["Dien_Giai"]), new SqlParameter("p_Desc_EN", row["Desc_EN"]), new SqlParameter("p_TMinh", row["TMinh"]), new SqlParameter("p_Stt_Bac", row["Stt_Bac"]), new SqlParameter("p_Cong_Thuc", row["Cong_Thuc"]), new SqlParameter("p_Loai_Ps", row["Loai_Ps"]), new SqlParameter("p_Loai_Tk", row["Loai_Tk"]), new SqlParameter("p_Tk_No", row["Tk_No"]), new SqlParameter("p_Tk_Co", row["Tk_Co"]), new SqlParameter("p_Not_Tk", row["Not_Tk"]), new SqlParameter("p_In_Ck", row["In_Ck"]), new SqlParameter("p_Bold", row["Bold"]), 
                new SqlParameter("p_Result", SqlDbType.BigInt)
             };
            values[1].Direction = ParameterDirection.InputOutput;
            values[1].SqlDbType = SqlDbType.Int;
            values[0x10].Direction = ParameterDirection.Output;
            values[0x10].SqlDbType = SqlDbType.Int;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT031_Save";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
                row["Stt"] = values[1].Value;
                num = (int) values[0x10].Value;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return num;
        }

        public DataSet KQT032GetDataSet()
        {
            DataSet set2;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            DataSet dataSet = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT032_Get";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet);
                AppDataAccess.CloseConnection(eZConnection);
                set2 = dataSet;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return set2;
        }

        public int KQT032Save(bool pb_NewChecked, DataRow row)
        {
            int num;
            SqlParameter[] values = new SqlParameter[] { new SqlParameter("p_Moi_Sua", pb_NewChecked), new SqlParameter("p_Stt", row["Stt"]), new SqlParameter("p_IDKey", row["IDKey"]), new SqlParameter("p_Stt0", row["Stt0"]), new SqlParameter("p_Dien_Giai", row["Dien_Giai"]), new SqlParameter("p_Desc_EN", row["Desc_EN"]), new SqlParameter("p_TMinh", row["TMinh"]), new SqlParameter("p_Stt_Bac", row["Stt_Bac"]), new SqlParameter("p_Cong_Thuc", row["Cong_Thuc"]), new SqlParameter("p_Tk_No", row["Tk_No"]), new SqlParameter("p_Tk_Co", row["Tk_Co"]), new SqlParameter("p_In_Ck", row["In_Ck"]), new SqlParameter("p_Bold", row["Bold"]), new SqlParameter("p_Result", SqlDbType.BigInt) };
            values[1].Direction = ParameterDirection.InputOutput;
            values[1].SqlDbType = SqlDbType.Int;
            values[13].Direction = ParameterDirection.Output;
            values[13].SqlDbType = SqlDbType.Int;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT032_Save";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
                row["Stt"] = values[1].Value;
                num = (int) values[13].Value;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return num;
        }

        public DataSet KQT05GetDataSet()
        {
            DataSet set2;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            DataSet dataSet = new DataSet();
            SqlDataAdapter adapter = new SqlDataAdapter();
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT05_Get";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                adapter.SelectCommand = command;
                adapter.Fill(dataSet);
                AppDataAccess.CloseConnection(eZConnection);
                set2 = dataSet;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return set2;
        }

        public int KQT05Save(bool pb_NewChecked, DataRow row)
        {
            int num;
            SqlParameter[] values = new SqlParameter[] { 
                new SqlParameter("p_Moi_Sua", pb_NewChecked), new SqlParameter("p_Stt", row["Stt"]), new SqlParameter("p_IDKey", row["IDKey"]), new SqlParameter("p_Stt0", row["Stt0"]), new SqlParameter("p_Dien_Giai", row["Dien_Giai"]), new SqlParameter("p_Desc_EN", row["Desc_EN"]), new SqlParameter("p_Series01", row["Series01"]), new SqlParameter("p_Series02", row["Series02"]), new SqlParameter("p_Stt_Bac", row["Stt_Bac"]), new SqlParameter("p_Cong_Thuc", row["Cong_Thuc"]), new SqlParameter("p_Bieu_Thuc", row["Bieu_Thuc"]), new SqlParameter("p_Vao_Ra", row["Vao_Ra"]), new SqlParameter("p_Dieu_Chinh", row["Dieu_Chinh"]), new SqlParameter("p_Thue_XNK", row["Thue_XNK"]), new SqlParameter("p_VAT_Ck", row["VAT_Ck"]), new SqlParameter("p_Thue_GTGT", row["Thue_GTGT"]), 
                new SqlParameter("p_Kieu_Ps", row["Kieu_Ps"]), new SqlParameter("p_In_Ck", row["In_Ck"]), new SqlParameter("p_Bold", row["Bold"]), new SqlParameter("p_Result", SqlDbType.BigInt)
             };
            values[1].Direction = ParameterDirection.InputOutput;
            values[1].SqlDbType = SqlDbType.Int;
            values[0x13].Direction = ParameterDirection.Output;
            values[0x13].SqlDbType = SqlDbType.Int;
            SqlConnection eZConnection = AppDataAccess.AppConnection;
            SqlCommand command = new SqlCommand();
            try
            {
                command.CommandText = "KQT05_Save";
                command.CommandType = CommandType.StoredProcedure;
                command.Connection = eZConnection;
                command.Parameters.AddRange(values);
                command.ExecuteNonQuery();
                AppDataAccess.CloseConnection(eZConnection);
                row["Stt"] = values[1].Value;
                num = (int) values[0x13].Value;
            }
            catch (Exception exception)
            {
                throw new NotSupportedException("Invalid expression", exception);
            }
            return num;
        }
    }
}

